<%@ Page Language="C#" MasterPageFile="~/SolaraTheme.Master" AutoEventWireup="true" CodeBehind="CRMMainView.aspx.cs" Inherits="WIntegrator.Pages.CRMMainView"  %>

<%@ Register Src="../Controls/CRM/CRMInformationView.ascx" TagName="CRMInformationView"
    TagPrefix="uc2" %>
<%@ Register Assembly="RadAjax.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <!--   Original Ajax Post Back -->
        <script language="javascript" type="text/javascript">
            function rowSelected(sender,eventArgs)
            {                               
                var index =eventArgs.getDataKeyValue("ID");                
                var xml = SendGetRequest(index);  
                OnComplete(xml.responseXML);                                                 
            }
            function SendGetRequest(index)
            {
                var pageUrl = "WSSolaraWebService.asmx/GetCompany?CompanyID="+index;                                                               
                return GetXMLRequestObject("GET",pageUrl,false);               
            }
            function GetXMLRequestObject(Type,PageUrl,Mode)
            {
                //Initialize the XmlHttpRequest object
                var xmlRequest , e;
                try
                {
                    xmlRequest = new XMLHttpRequest();                    
                }
                catch (e)
                {
                    try
                    {
                        xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    catch (e) {}
                }
                //Prepare for a POST synchronous request
                try
                {
                    xmlRequest.open (Type,PageUrl,Mode); //Mode Async True/False
                    xmlRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
                    xmlRequest.send(null);
                }
                catch(e)
                {   throw e }                
                return xmlRequest;
            }
        </script>
<!-- Menu Client Functions -->
<script language="javascript" type="text/javascript">
            function OnComplete(response)
            {
                //Company Information                
                //Company Name                                         
                var companyName =(response.documentElement.getElementsByTagName('CompanyName')[0].firstChild !=null)?response.documentElement.getElementsByTagName('CompanyName')[0].firstChild.nodeValue:"";                                       
                var ctrlCompanyName = $find('<%=txtCompanyName.ClientID%>');
                ctrlCompanyName.set_value(companyName);
                //Company Address
                var companyAddress =(response.documentElement.getElementsByTagName('AddressBlock')[0].firstChild !=null)?response.documentElement.getElementsByTagName('AddressBlock')[0].firstChild.nodeValue:"";   
                var ctrlCompanyAddress = $find('<%=txtCompanyAddress.ClientID%>');
                ctrlCompanyAddress.set_value(companyAddress);
                //Company City                
                var companyCity =  (response.documentElement.getElementsByTagName('City')[0].firstChild != null)?response.documentElement.getElementsByTagName('City')[0].firstChild.nodeValue:"";                  
                var ctrlCompanyCity = $find('<%=txtCompanyCity.ClientID%>');
                ctrlCompanyCity.set_value(companyCity);
                //Company State                
                var companyState = (response.documentElement.getElementsByTagName('State')[0].firstChild !=null)?response.documentElement.getElementsByTagName('State')[0].firstChild.nodeValue:""; 
                var ctrlCompanyState = $find('<%=txtCompanyState.ClientID%>');
                ctrlCompanyState.set_value(companyState);
                //Company ZipCode  
                var companyZipCode = (response.documentElement.getElementsByTagName('ZipCode')[0].firstChild !=null)?response.documentElement.getElementsByTagName('ZipCode')[0].firstChild.nodeValue:"";                             
                var ctrlCompanyZipCode = $find('<%=txtCompanyZipCode.ClientID%>');
                ctrlCompanyZipCode.set_value(companyZipCode);               
                //Company Phone
                var companyPhone =(response.documentElement.getElementsByTagName('Phone')[0].firstChild !=null)?response.documentElement.getElementsByTagName('Phone')[0].firstChild.nodeValue:"";                                       
                var ctrlCompanyPhone = $find('<%=txtCompanyPhone.ClientID%>');
                ctrlCompanyPhone.set_value(companyPhone);
                //Company Fax
                var companyFax =(response.documentElement.getElementsByTagName('Fax')[0].firstChild !=null)?response.documentElement.getElementsByTagName('Fax')[0].firstChild.nodeValue:"";                                       
                var ctrlCompanyFax = $find('<%=txtCompanyFax.ClientID%>');
                ctrlCompanyFax.set_value(companyFax);                
                //Website
                var webSite =(response.documentElement.getElementsByTagName('WebSite')[0].firstChild !=null)?response.documentElement.getElementsByTagName('WebSite')[0].firstChild.nodeValue:"";                                       
                var ctrlWebsite = $find('<%=txtWebsite.ClientID%>');
                ctrlWebsite.set_value(webSite);                
                //Ftpsite
                var ftpSite =(response.documentElement.getElementsByTagName('FtpSite')[0].firstChild !=null)?response.documentElement.getElementsByTagName('FtpSite')[0].firstChild.nodeValue:"";                                       
                var ctrlFtpsite = $find('<%=txtFtpsite.ClientID%>');
                ctrlFtpsite.set_value(ftpSite);                
                //Sales Rep
                var salesRep =(response.documentElement.getElementsByTagName('SalesRep')[0].firstChild !=null)?response.documentElement.getElementsByTagName('SalesRep')[0].firstChild.nodeValue:"";                                       
                var ctrlSalesRep = $find('<%=txtSalesRep.ClientID%>');
                ctrlSalesRep.set_value(salesRep);   
                //Sales Terms
                var salesTerms =(response.documentElement.getElementsByTagName('SalesTerms')[0].firstChild !=null)?response.documentElement.getElementsByTagName('SalesTerms')[0].firstChild.nodeValue:"";                                       
                var ctrlSalesRep = $find('<%=txtSalesTerms.ClientID%>');
                ctrlSalesRep.set_value(salesTerms);    
                                                                  
            }
function MenuClicked()
{
   var form = document.getElementById("form1");
   form.reset();
}
</script>
<div id="toolBar">
<table width="100%">
<tr valign="top">
<td align="left">
    <telerik:RadMenu ID="RadMenu1" runat="server" Skin="WebBlue" width="1150px" 
             OnItemClick="RadMenu1_ItemClick" 
             OnClientItemClicked="MenuClicked" >        
        <CollapseAnimation Duration="200" Type="OutQuint" />
        <Items>
            <telerik:RadMenuItem runat="server" Text="New">
            </telerik:RadMenuItem>          
            <telerik:RadMenuItem runat="server" Text="Save">                
            </telerik:RadMenuItem>              
        </Items>
    </telerik:RadMenu>
</td>
</tr>
</table>
</div>
<div id="Main">
        <rad:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <rad:AjaxSetting AjaxControlID="RadMenu1">
                    <UpdatedControls>
                        <rad:AjaxUpdatedControl ControlID="grdCustomers" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </rad:AjaxSetting>
                <rad:AjaxSetting AjaxControlID="grdCustomers">
                    <UpdatedControls>
                        <rad:AjaxUpdatedControl ControlID="grdCustomers" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </rad:AjaxSetting>
            </AjaxSettings>
        </rad:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel id="RadAjaxLoadingPanel1" Runat="server" height="75px"
            width="75px">
            <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
                style="border: 0px;" />
        </telerik:RadAjaxLoadingPanel>                                   
   <telerik:RadSplitter ID="RadSplitter2" runat="server" LiveResize="True" Skin="WebBlue" Width="1200px" Orientation="Vertical"  Height="600px" >                             
            <telerik:RadPane ID="leftPanel" runat="server" width="200px" Scrolling="None">
              <telerik:RadGrid ID="grdCustomers" runat="server" 
                AllowFilteringByColumn="True" AutoGenerateColumns="False"                 
                GridLines="None" Skin="WebBlue">
                <MasterTableView DataKeyNames="ID" ClientDataKeyNames="ID">
                    <RowIndicatorColumn Visible="False">
                        <HeaderStyle Width="20px" />
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn Resizable="False" Visible="False">
                        <HeaderStyle Width="20px" />
                    </ExpandCollapseColumn>
                    <EditFormSettings>
                        <PopUpSettings ScrollBars="None" />
                    </EditFormSettings>
                    <Columns>
                        <telerik:GridBoundColumn DataField="CompanyName" UniqueName="CompanyName" />                        
                    </Columns>
                </MasterTableView>               
                <ClientSettings>   
                    <Selecting AllowRowSelect="True" />                                                         
                    <ClientEvents OnRowSelected="rowSelected"/>
                </ClientSettings>
            </telerik:RadGrid>                   
            </telerik:RadPane>
            <telerik:RadSplitBar ID="SplitBar1" runat="server" CollapseMode="Both"/>
            <telerik:RadPane ID="rightPanel" runat="server" Scrolling="none">
                    <telerik:RadSplitter ID="RadSplitter1" runat="server" LiveResize="True" Skin="WebBlue" Width="1000px" Orientation="Horizontal">
                       <telerik:RadPane ID="topContent" runat="server">
<table width="980" border="0">
  <tr>
    <td colspan="5">Customer Information </td>
      <td colspan="1">
      </td>
  </tr>
  <tr>
      <td colspan="6">
          <hr>
      </td>
  </tr>
  <tr valign="top">
    <td style="width: 180px">Company Name: </td>
    <td width="180"><telerik:RadTextBox ID="txtCompanyName" runat="server" Skin="WebBlue" Width="193px">
        </telerik:RadTextBox></td>
    <td width="194">&nbsp;Office:</td>
    <td width="194"><telerik:RadComboBox ID="cmbOffice" runat="server" Skin="WebBlue">
        <CollapseAnimation Duration="200" Type="OutQuint" />
    </telerik:RadComboBox>
    </td>
    <td style="width: 198px">&nbsp;Contact:</td>
      <td width="198">
          <telerik:RadComboBox ID="cmbContact" runat="server" Skin="WebBlue">
              <CollapseAnimation Duration="200" Type="OutQuint" />
          </telerik:RadComboBox>
      </td>
  </tr>
  <tr valign="top">
    <td style="width: 160px"> Address:</td>
    <td>
        <telerik:RadTextBox ID="txtCompanyAddress" runat="server" Skin="WebBlue" Enabled="true" TextMode="MultiLine" Width="200px">
        </telerik:RadTextBox></td>
    <td>&nbsp;Address:</td>
    <td><telerik:RadTextBox ID="txtOfficeAddress" runat="server" Skin="WebBlue" Enabled="true" TextMode="MultiLine" Width="200px">
    </telerik:RadTextBox></td>
    <td style="width: 198px">&nbsp;Phone:</td>
      <td>
          <telerik:RadTextBox ID="txtContactPhone" runat="server" Skin="WebBlue">
          </telerik:RadTextBox></td>
  </tr>
    <tr valign="top">
        <td style="width: 160px">
            City:</td>
        <td><telerik:RadTextBox ID="txtCompanyCity" runat="server" Skin="WebBlue" Width="193px">
        </telerik:RadTextBox></td>
        <td>
            City:</td>
        <td><telerik:RadTextBox ID="txtOfficeCity" runat="server" Skin="WebBlue" Width="193px">
        </telerik:RadTextBox></td>
        <td style="width: 198px">
        </td>
        <td>
        </td>
    </tr>
    <tr valign="top">
        <td style="width: 160px">
            State:</td>
        <td><telerik:RadTextBox ID="txtCompanyState" runat="server" Skin="WebBlue" Width="42px">
        </telerik:RadTextBox></td>
        <td>
            State:</td>
        <td><telerik:RadTextBox ID="txtOfficeState" runat="server" Skin="WebBlue" Width="42px">
        </telerik:RadTextBox></td>
        <td style="width: 198px">
        </td>
        <td>
        </td>
    </tr>
    <tr valign="top">
        <td style="width: 160px">
            ZipCode:</td>
        <td><telerik:RadTextBox ID="txtCompanyZipCode" runat="server" Skin="WebBlue">
        </telerik:RadTextBox></td>
        <td>
            ZipCode:</td>
        <td><telerik:RadTextBox ID="txtOfficeZipCode" runat="server" Skin="WebBlue">
        </telerik:RadTextBox></td>
        <td style="width: 198px">
        </td>
        <td>
        </td>
    </tr>
  <tr valign="top">
    <td style="width: 160px">&nbsp;Phone:</td>
    <td><telerik:RadTextBox ID="txtCompanyPhone" runat="server" Skin="WebBlue">
    </telerik:RadTextBox></td>
    <td>&nbsp;Phone:</td>
    <td><telerik:RadTextBox ID="txtOfficePhone" runat="server" Skin="WebBlue">
    </telerik:RadTextBox></td>
    <td style="width: 198px">&nbsp;Mobile</td>
      <td>
          <telerik:RadTextBox ID="txtContactMobile" runat="server" Skin="WebBlue">
          </telerik:RadTextBox></td>
  </tr>
  <tr valign="top">
    <td style="width: 160px">&nbsp;Fax:</td>
    <td>
        <telerik:RadTextBox ID="txtCompanyFax" runat="server" Skin="WebBlue">
        </telerik:RadTextBox></td>
    <td></td>
    <td></td>
    <td style="width: 198px">&nbsp;Email</td>
      <td>
          <telerik:RadTextBox ID="txtContactEmail" runat="server" Skin="WebBlue">
          </telerik:RadTextBox></td>
  </tr>
    <tr valign="top">
        <td style="width: 160px">
            Website:</td>
        <td>
            <telerik:RadTextBox ID="txtWebsite" runat="server" Skin="WebBlue" Width="193px">
            </telerik:RadTextBox></td>
        <td>
        </td>
        <td>
        </td>
        <td style="width: 198px">
            &nbsp;Contact Type:</td>
        <td>
          <telerik:RadComboBox ID="cmbContactType" runat="server" Skin="WebBlue">
              <CollapseAnimation Duration="200" Type="OutQuint" />
          </telerik:RadComboBox>
      </td>
    </tr>
    <tr valign="top">
        <td style="width: 160px">
            &nbsp;Ftpsite:</td>
        <td>
            <telerik:RadTextBox ID="txtFtpsite" runat="server" Skin="WebBlue" Width="193px">
            </telerik:RadTextBox></td>
        <td>
        </td>
        <td>
        </td>
        <td style="width: 198px">
            &nbsp;Referral:</td>
        <td>
          <telerik:RadComboBox ID="cmbReferal" runat="server" Skin="WebBlue">
              <CollapseAnimation Duration="200" Type="OutQuint" />
          </telerik:RadComboBox>
      </td>
    </tr>
    <tr valign="top">
        <td style="width: 160px">
            Sales Rep:</td>
        <td>
            <telerik:RadTextBox ID="txtSalesRep" runat="server" Skin="WebBlue" Width="193px">
        </telerik:RadTextBox></td>
        <td>
        </td>
        <td>
        </td>
        <td style="width: 198px">
        </td>
        <td>
        </td>
    </tr>
    <tr valign="top">
        <td style="width: 160px">
            Sales Terms:</td>
        <td>
            <telerik:RadTextBox ID="txtSalesTerms" runat="server" Skin="WebBlue" Width="193px">
        </telerik:RadTextBox></td>
        <td>
        </td>
        <td>
        </td>
        <td style="width: 198px">
        </td>
        <td>
        </td>
    </tr>
  <tr valign="top">
    <td style="width: 160px">Company Type:
    </td>
    <td><telerik:RadComboBox ID="cmbCompanyType" runat="server" Skin="WebBlue">
            <CollapseAnimation Duration="200" Type="OutQuint" />
        </telerik:RadComboBox>
    </td>
    <td>&nbsp;</td>
    <td></td>
    <td style="width: 198px">&nbsp;</td>
      <td>
          &nbsp;</td>
  </tr>
  <tr valign="top">
    <td style="width: 160px">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td style="width: 198px">&nbsp;</td>
      <td>
          &nbsp;</td>
  </tr>
</table>                           
                       </telerik:RadPane>
                       <telerik:RadSplitBar ID="SplitBar2" runat="server" CollapseMode="Both" />
                       <telerik:RadPane ID="bottomContent" runat="server">
                           <uc2:CRMInformationView id="CRMInformationView1" runat="server">
                           </uc2:CRMInformationView>
                       </telerik:RadPane>
                    </telerik:RadSplitter>
            </telerik:RadPane>            
   </telerik:RadSplitter>   
   </div>     
    
</asp:Content>
